﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace www.interviewstreet.com.KDifference
{
    class Program
    {
        static void Main(string[] args)
        {

            //string lineOne = "10 1";
            //string lineTwo = "363374326 364147530 61825163 1073065718 1281246024 1399469912 428047635 491595254 879792181 1069262793";

            #region read input from file
            //using (StreamReader sr = new StreamReader("input\\input01.txt"))
            //{
            //    String line;
            //    // Read and display lines from the file until the end of
            //    // the file is reached.
            //    string lineOne = sr.ReadLine();
            //    string lineTwo = sr.ReadLine();
            //}
            #endregion

            #region input from console

            string lineOne = Console.ReadLine();
            string lineTwo = Console.ReadLine();
            #endregion

            #region form input


            string[] temp = lineOne.Split(' ');
            decimal N = Convert.ToDecimal(temp[0]);
            decimal K = Convert.ToDecimal(temp[1]);

            temp = lineTwo.Split(' ');

            Dictionary<decimal, decimal> lookup = new Dictionary<decimal, decimal>();

            foreach (string t in temp)
            {
                lookup.Add(Convert.ToDecimal(t),Convert.ToDecimal(t));
            }

            #endregion



            #region code
            int count = 0;
            decimal valueTemp = 0;
            foreach (var value in lookup)
            {
                valueTemp = value.Value - K;
                if(valueTemp<0)
                {
                    valueTemp = valueTemp*-1;
                }

                if (lookup.ContainsKey(valueTemp) && valueTemp != value.Value)
                {
                    count = count + 1;
                }

            }
            
            Console.WriteLine("{0}",count);
            
            #endregion
        }
    }
}
